<?php

abstract class AbstractObject
{
    public function __construct(protected string $name)
    {
    }

    public function getObjectName(): string
    {
        return $this->name;
    }

    public function handle(): string
    {
        return 'handle_' . $this->name;
    }

}

class SomeObject1 extends AbstractObject
{
}

class SomeObject2 extends AbstractObject
{
}

class SomeObjectsHandler
{
    public function handleObjects(array $objects): array
    {
        $handlers = [];
        foreach ($objects as $object) {
            if ($object instanceof AbstractObject) {
                $handlers[] = $object->handle();
            }
        }

        return $handlers;
    }
}


$objects = [
    new SomeObject1('object_1'),
    new SomeObject2('object_2')
];

$soh = new SomeObjectsHandler();
$soh->handleObjects($objects);
